<template>
    <div class="list-page">
        <tool-bar nav="" title="发布单">
            <el-button @click="add_click()">添加</el-button>
        </tool-bar>
        <my-list
            ref="list"
            url="/dev/deploy-sheet/list"
            @param="preload"
            @loaded="procData"
            :page-size="10"
            :store="true"
            :query="query"
        >
            <el-table-column label="名称" align="center" width="160px">
                <template v-slot="scope">
                    <div class="link" @click="edit_click(scope.row)">{{ scope.row.name }}</div>
                </template>
            </el-table-column>
            <el-table-column align="center" label="产品线" prop="productLine.name"  width="160px"></el-table-column>

            <el-table-column align="left" label="items" prop="items">
                <template v-slot="scope">
                    <kp v-for="(item,index) in scope.row.items" :key="index" :label="item.gitData.name">
                        {{item.buildFolder}}:
                        {{item.gitBranch}}
                    </kp>
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center" width="100px">
                <template v-slot="scope">

                    <el-button type="warning" plain round @click="delete_click(scope.row)" size="small">
                        删除
                    </el-button>
                </template>
            </el-table-column>
            <template #query="scope">
                <kv label="产品线">
                    <product-line :key="scope.query.language" :language="scope.query.language" clearable
                                  v-model="scope.query.productLine" chk="*"
                                  ></product-line>
             </kv>
                <kv label="名称"><el-input v-model="scope.query.name"></el-input></kv>
            </template>
        </my-list>
    </div>
</template>

<script setup>
import productLine from "@/component/product-line.vue";

/**
 * Created by CodeGenerator at 2024-01-23 12:48:15
 */




//定义 vue2的this,当前组件
const $self = getCurrentInstance();

//定义 $attrs
const $attrs = useAttrs();



//定义data
const $data = reactive( {
    //默认查询条件,默认存储
    query:{},
    JenkinsLanguageEnum: jv.enum.JenkinsLanguageEnum.getData(),
    SystemEnvEnum: jv.enum.SystemEnvEnum.getData(),
    MicroServiceDeployEnvEnum: jv.enum.MicroServiceDeployEnvEnum.getData(),
});


const $props = defineProps({

});





const list = ref();

//定义事件
const $emit = defineEmits(["update:modelValue","loaded"]);



const preload = function(param) {
//保存查询条件
//添加查询参数，修改分页参数等。
//param.type = jv.$route.params.type
};
const procData = function(res) {
    res.data.data.forEach(it => {
//如果是组合实体，设置 it.id=...
    });
};
const loadData = function(pageNumber) {
    list.value.loadData(pageNumber);
};
const add_click = function() {
    jv.$router.push("/dev/deploy-sheet/add")
};
const edit_click = function(row) {
//记录上次点击行
    let rowId = row.id;
    list.value.setLastRow(row);
    jv.$router.push("/dev/deploy-sheet/edit/" + rowId)
};
const delete_click = async function(row) {
    let rowId = row.id,rowName = row.name;
    await jv.confirm('确认删除 ' + rowName + ' 吗？');
    let res = await jv.$http.post("/dev/deploy-sheet/delete/" + rowId)
    loadData();
};

onMounted( function() {
//加载存储的查询条件
} )



</script>

<style scoped lang="scss">
</style>
